#ifndef __SLAVE_WORKER__
#define __SLAVE_WORKER__
#include "encode_decode.h"
#include <mpi.h>
#include <stdio.h>
#include "cdcl.h"
extern MPI_Datatype mpi_metadata_t;

MPI_Request slv_send_metadata(int t, unsigned len);
MPI_Request slv_send_encoded_data(unsigned* encoded,  int len);

int _slvprintf(int rank, const char *__restrict__ __format, ...);

typedef struct _slaveworker{
    int rank;
    _bool inited;
    _bool is_stop;    
    cdcl_config config;
    cdcl* cdcl;
    cnf* cnf;
}slaveworker;

void init_worker(slaveworker* worker, int rank, cnf* _cnf);
void update_config(slaveworker* worker, const cdcl_config* config);
void block_wait_for_instructions_from_master(slaveworker* worker);
#endif